//
//  UIBarButtonItem+YSLExtension.m
//  iOS-百思不得姐
//
//  Created by lanou on 16/6/30.
//  Copyright © 2016年 杨斯霖. All rights reserved.
//

#import "UIBarButtonItem+YSLExtension.h"

@implementation UIBarButtonItem (YSLExtension)

+ (instancetype)itemWithImage:(NSString *)image
                    highImage:(NSString *)highImage
                       target:(id)target
                       action:(SEL)action
{

    //设置导航栏左边的按钮
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    
    [button setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    
    button.size = button.currentBackgroundImage.size;
    
    //点击事件
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    return [[self alloc] initWithCustomView:button];
}

@end
